﻿using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;

using System.Configuration;
using System.Text;


/// <summary>
/// Service1 的摘要说明
/// </summary>
[WebService(Namespace = "http://198.198.192.3:1110/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务，请取消对下行的注释。
// [System.Web.Script.Services.ScriptService]
public class ZXGZ_WebService : System.Web.Services.WebService
{
    public static string DB2ConnectionString = ConfigurationManager.ConnectionStrings["DB2"].ConnectionString;
    public static DB2Service.DB2ServiceClass dbService = new DB2Service.DB2ServiceClass();
    //1
    [WebMethod]
    public string Save_B_ZXGZ_BLKF(string FYDM, string AJBS, string AJBH, string XH, string CBTS, string CBR, string AHYEAR, string AHZ, string AHZT, string AHH, string CURDOCID, string CBSPTBS, string BLKFFSRQ, string BLKFRY, string BLKFRYHJ, string SFGJSS, string GJSSQK, string SFCWSS, string CWSSQK, string BLKFCLFS, string BLKFCLJG, string BLKFBZ)
    {


        string[] columnNames = new string[] { "FYDM", "AJBS", "AJBH", "XH", "CBTS", "CBR", "AHYEAR", "AHZ", "AHZT", "AHH", "CURDOCID", "CBSPTBS", "BLKFFSRQ", "BLKFRY", "BLKFRYHJ", "SFGJSS", "GJSSQK", "SFCWSS", "CWSSQK", "BLKFCLFS", "BLKFCLJG", "BLKFBZ" };
        string tableName = "B_ZXGZ_BLKF";
        try
        {
            DeleteExist(tableName, AJBS, CURDOCID);
            string sqlStr = createInserSqlStr(tableName, columnNames);
            dbService.ExecuteNonQuery(sqlStr, DB2ConnectionString, createHasTable(columnNames, FYDM, AJBS, AJBH, XH, CBTS, CBR, AHYEAR, AHZ, AHZT, AHH, CURDOCID, CBSPTBS, BLKFFSRQ, BLKFRY, BLKFRYHJ, SFGJSS, GJSSQK, SFCWSS, CWSSQK, BLKFCLFS, BLKFCLJG, BLKFBZ));
        }
        catch (Exception ex)
        {
            return ex.ToString();
        }
        return "success";


    }
    //2
    [WebMethod]
    public string Save_B_ZXGZ_BM(string FYDM, string AJBS, string AJBH, string XH, string CBTS, string CBR, string AHYEAR, string AHZ, string AHZT, string AHH, string CURDOCID, string BMYY, string BMZE, string CBSPTBS, string BDWQD, string SYQR, string MSRMC, string BMKSRQ, string BMJSRQ, string CKJG, string BMJG)
    {


        string[] columnNames = new string[] { "FYDM", "AJBS", "AJBH", "XH", "CBTS", "CBR", "AHYEAR", "AHZ", "AHZT", "AHH", "CURDOCID", "BMYY", "BMZE", "CBSPTBS", "BDWQD", "SYQR", "MSRMC", "BMKSRQ", "BMJSRQ", "CKJG", "BMJG" };
        string tableName = "B_ZXGZ_BM";
        try
        {
            DeleteExist(tableName, AJBS, CURDOCID);
            string sqlStr = createInserSqlStr(tableName, columnNames);
            dbService.ExecuteNonQuery(sqlStr, DB2ConnectionString, createHasTable(columnNames, FYDM, AJBS, AJBH, XH, CBTS, CBR, AHYEAR, AHZ, AHZT, AHH, CURDOCID, BMYY, BMZE, CBSPTBS, BDWQD, SYQR, MSRMC, BMKSRQ, BMJSRQ, CKJG, BMJG));
        }
        catch (Exception ex)
        {
            return ex.ToString();
        }
        return "success";


    }
    //3
    [WebMethod]
    public string Save_B_ZXGZ_CF(string FYDM, string AJBS, string AJBH, string XH, string CBTS, string CBR, string AHYEAR, string AHZ, string AHZT, string AHH, string CURDOCID, string CFLX, string JFRQ, string CDXFRQ, string XLXMRQ, string XLXMLB, string CBSPTBS, string CFQD, string CFWSYR, string BGR, string CFSXRQ, string XFJMRQ, string CFJMRQ, string NZXBDE, string UICFFF)
    {


        string[] columnNames = new string[] { "FYDM", "AJBS", "AJBH", "XH", "CBTS", "CBR", "AHYEAR", "AHZ", "AHZT", "AHH", "CURDOCID", "CFLX", "JFRQ", "CDXFRQ", "XLXMRQ", "XLXMLB", "CBSPTBS", "CFQD", "CFWSYR", "BGR", "CFSXRQ", "XFJMRQ", "CFJMRQ", "NZXBDE", "UICFFF" };
        string tableName = "B_ZXGZ_CF";
        try
        {
            DeleteExist(tableName, AJBS, CURDOCID);
            string sqlStr = createInserSqlStr(tableName, columnNames);
            dbService.ExecuteNonQuery(sqlStr, DB2ConnectionString, createHasTable(columnNames, FYDM, AJBS, AJBH, XH, CBTS, CBR, AHYEAR, AHZ, AHZT, AHH, CURDOCID, CFLX, JFRQ, CDXFRQ, XLXMRQ, XLXMLB, CBSPTBS, CFQD, CFWSYR, BGR, CFSXRQ, XFJMRQ, CFJMRQ, NZXBDE, UICFFF));
        }
        catch (Exception ex)
        {
            return ex.ToString();
        }
        return "success";


    }
    //4
    [WebMethod]
    public string Save_B_ZXGZ_DJ(string FYDM, string AJBS, string AJBH, string XH, string CBTS, string CBR, string AHYEAR, string AHZ, string AHZT, string AHH, string CURDOCID, string DJLX, string NZXBDE, string BFJDRQ, string CDXDRQ, string XLXMRQ, string XLXMLB, string DJSXRQ, string CBSPTBS, string DJJMRQ, string XDJMRQ, string DJQD, string CCSYQR, string UIDJLX, string UITQFS)
    {


        string[] columnNames = new string[] { "FYDM", "AJBS", "AJBH", "XH", "CBTS", "CBR", "AHYEAR", "AHZ", "AHZT", "AHH", "CURDOCID", "DJLX", "NZXBDE", "BFJDRQ", "CDXDRQ", "XLXMRQ", "XLXMLB", "DJSXRQ", "CBSPTBS", "DJJMRQ", "XDJMRQ", "DJQD", "CCSYQR", "UIDJLX", "UITQFS" };
        string tableName = "B_ZXGZ_DJ";
        try
        {
            DeleteExist(tableName, AJBS, CURDOCID);
            string sqlStr = createInserSqlStr(tableName, columnNames);
            dbService.ExecuteNonQuery(sqlStr, DB2ConnectionString, createHasTable(columnNames, FYDM, AJBS, AJBH, XH, CBTS, CBR, AHYEAR, AHZ, AHZT, AHH, CURDOCID, DJLX, NZXBDE, BFJDRQ, CDXDRQ, XLXMRQ, XLXMLB, DJSXRQ, CBSPTBS, DJJMRQ, XDJMRQ, DJQD, CCSYQR, UIDJLX, UITQFS));
        }
        catch (Exception ex)
        {
            return ex.ToString();
        }
        return "success";


    }
    //5
    [WebMethod]
    public string Save_B_ZXGZ_FK(string FYDM, string AJBS, string AJBH, string XH, string CBTS, string CBR, string AHYEAR, string AHZ, string AHZT, string AHH, string CURDOCID, string FKJE, string FKYY, string FKRQ, string CBSPTBS, string BFKR, string UIFKYY, string LXRQ)
    {


        string[] columnNames = new string[] { "FYDM", "AJBS", "AJBH", "XH", "CBTS", "CBR", "AHYEAR", "AHZ", "AHZT", "AHH", "CURDOCID", "FKJE", "FKYY", "FKRQ", "CBSPTBS", "BFKR", "UIFKYY", "LXRQ" };
        string tableName = "B_ZXGZ_FK";
        try
        {
            DeleteExist(tableName, AJBS, CURDOCID);
            string sqlStr = createInserSqlStr(tableName, columnNames);
            dbService.ExecuteNonQuery(sqlStr, DB2ConnectionString, createHasTable(columnNames, FYDM, AJBS, AJBH, XH, CBTS, CBR, AHYEAR, AHZ, AHZT, AHH, CURDOCID, FKJE, FKYY, FKRQ, CBSPTBS, BFKR, UIFKYY, LXRQ));
        }
        catch (Exception ex)
        {
            return ex.ToString();
        }
        return "success";


    }
    //6
    [WebMethod]
    public string Save_B_ZXGZ_FZYS(string FYDM, string AJBS, string AJBH, string XH, string CBTS, string CBR, string AHYEAR, string AHZ, string AHZT, string AHH, string CURDOCID, string YSYY, string YSRQ, string CBSPTBS, string FZXYR, string SYDW, string UIYSYY)
    {


        string[] columnNames = new string[] { "FYDM", "AJBS", "AJBH", "XH", "CBTS", "CBR", "AHYEAR", "AHZ", "AHZT", "AHH", "CURDOCID", "YSYY", "YSRQ", "CBSPTBS", "FZXYR", "SYDW", "UIYSYY" };
        string tableName = "B_ZXGZ_FZYS";
        try
        {
            DeleteExist(tableName, AJBS, CURDOCID);
            string sqlStr = createInserSqlStr(tableName, columnNames);
            dbService.ExecuteNonQuery(sqlStr, DB2ConnectionString, createHasTable(columnNames, FYDM, AJBS, AJBH, XH, CBTS, CBR, AHYEAR, AHZ, AHZT, AHH, CURDOCID, YSYY, YSRQ, CBSPTBS, FZXYR, SYDW, UIYSYY));
            
        }
        catch (Exception ex)
        {
            return ex.ToString();
        }
        return "success";


    }
    //7
    [WebMethod]
    public string Save_B_ZXGZ_JL(string FYDM, string AJBS, string AJBH, string XH, string CBTS, string CBR, string AHYEAR, string AHZ, string AHZT, string AHH, string CURDOCID, string BJLR, string JLYY, string KSRQ, string CBSPTBS, string JLDD, string UIJLYY, string JLDQR, string CLJG)
    {


        string[] columnNames = new string[] { "FYDM", "AJBS", "AJBH", "XH", "CBTS", "CBR", "AHYEAR", "AHZ", "AHZT", "AHH", "CURDOCID", "BJLR", "JLYY", "KSRQ", "CBSPTBS", "JLDD", "UIJLYY", "JLDQR", "CLJG" };
        string tableName = "B_ZXGZ_JL";
        try
        {
            DeleteExist(tableName, AJBS, CURDOCID);
            string sqlStr = createInserSqlStr(tableName, columnNames);
            dbService.ExecuteNonQuery(sqlStr, DB2ConnectionString, createHasTable(columnNames, FYDM, AJBS, AJBH, XH, CBTS, CBR, AHYEAR, AHZ, AHZT, AHH, CURDOCID, BJLR, JLYY, KSRQ, CBSPTBS, JLDD, UIJLYY, JLDQR, CLJG));
        }
        catch (Exception ex)
        {
            return ex.ToString();
        }
        return "success";


    }
    //8
    [WebMethod]
    public string Save_B_ZXGZ_KY(string FYDM, string AJBS, string AJBH, string XH, string CBTS, string CBR, string AHYEAR, string AHZ, string AHZT, string AHH, string CURDOCID, string KYLX, string NZXBDE, string BFJKRQ, string CDXKRQ, string XLXMRQ, string XLXMLB, string KYSXRQ, string CBSPTBS, string KYJMRQ, string XKJMRQ, string KYQD, string CCSYQR, string UIKYLX, string BGR)
    {


        string[] columnNames = new string[] { "FYDM", "AJBS", "AJBH", "XH", "CBTS", "CBR", "AHYEAR", "AHZ", "AHZT", "AHH", "CURDOCID", "KYLX", "NZXBDE", "BFJKRQ", "CDXKRQ", "XLXMRQ", "XLXMLB", "KYSXRQ", "CBSPTBS", "KYJMRQ", "XKJMRQ", "KYQD", "CCSYQR", "UIKYLX", "BGR" };
        string tableName = "B_ZXGZ_KY";
        try
        {
            DeleteExist(tableName, AJBS, CURDOCID);
            string sqlStr = createInserSqlStr(tableName, columnNames);
            dbService.ExecuteNonQuery(sqlStr, DB2ConnectionString, createHasTable(columnNames, FYDM, AJBS, AJBH, XH, CBTS, CBR, AHYEAR, AHZ, AHZT, AHH, CURDOCID, KYLX, NZXBDE, BFJKRQ, CDXKRQ, XLXMRQ, XLXMLB, KYSXRQ, CBSPTBS, KYJMRQ, XKJMRQ, KYQD, CCSYQR, UIKYLX, BGR));
        }
        catch (Exception ex)
        {
            return ex.ToString();
        }
        return "success";


    }
    //9
    [WebMethod]
    public string Save_B_ZXGZ_PG(string FYDM, string AJBS, string AJBH, string XH, string CBTS, string CBR, string AHYEAR, string AHZ, string AHZT, string AHH, string CURDOCID, string SDPGBGRQ, string TCYYRQ, string PGJ, string PGFY, string PGKSRQ, string CBSPTBS, string BDWQD, string SYQR, string PGJGMC, string PGJSRQ)
    {


        string[] columnNames = new string[] { "FYDM", "AJBS", "AJBH", "XH", "CBTS", "CBR", "AHYEAR", "AHZ", "AHZT", "AHH", "CURDOCID", "SDPGBGRQ", "TCYYRQ", "PGJ", "PGFY", "PGKSRQ", "CBSPTBS", "BDWQD", "SYQR", "PGJGMC", "PGJSRQ" };
        string tableName = "B_ZXGZ_PG";
        try
        {
            DeleteExist(tableName, AJBS, CURDOCID);
            string sqlStr = createInserSqlStr(tableName, columnNames);
            dbService.ExecuteNonQuery(sqlStr, DB2ConnectionString, createHasTable(columnNames, FYDM, AJBS, AJBH, XH, CBTS, CBR, AHYEAR, AHZ, AHZT, AHH, CURDOCID, SDPGBGRQ, TCYYRQ, PGJ, PGFY, PGKSRQ, CBSPTBS, BDWQD, SYQR, PGJGMC, PGJSRQ));
        }
        catch (Exception ex)
        {
            return ex.ToString();
        }
        return "success";


    }
    //10
    [WebMethod]
    public string Save_B_ZXGZ_PM(string FYDM, string AJBS, string AJBH, string XH, string CBTS, string CBR, string AHYEAR, string AHZ, string AHZT, string AHH, string CURDOCID, string PMJG, string PGJ, string CJJG, string HRJE, string SYQZYRQ, string BMKSRQ, string CBSPTBS, string BDWQD, string SYQR, string PMJGMC, string PMJSRQ, string PMRQ)
    {


        string[] columnNames = new string[] { "FYDM", "AJBS", "AJBH", "XH", "CBTS", "CBR", "AHYEAR", "AHZ", "AHZT", "AHH", "CURDOCID", "PMJG", "PGJ", "CJJG", "HRJE", "SYQZYRQ", "BMKSRQ", "CBSPTBS", "BDWQD", "SYQR", "PMJGMC", "PMJSRQ", "PMRQ" };
        string tableName = "B_ZXGZ_PM";
        try
        {
            DeleteExist(tableName, AJBS, CURDOCID);
            string sqlStr = createInserSqlStr(tableName, columnNames);

            dbService.ExecuteNonQuery(sqlStr, DB2ConnectionString, createHasTable(columnNames, FYDM, AJBS, AJBH, XH, CBTS, CBR, AHYEAR, AHZ, AHZT, AHH, CURDOCID, PMJG, PGJ, CJJG, HRJE, SYQZYRQ, BMKSRQ, CBSPTBS, BDWQD, SYQR, PMJGMC, PMJSRQ, PMRQ));
        }
        catch (Exception ex)
        {
            return ex.ToString();
        }
        return "success";


    }
    //11
    [WebMethod]
    public string Save_B_ZXGZ_XZ(string FYDM, string AJBS, string AJBH, string XH, string CBTS, string CBR, string AHYEAR, string AHZ, string AHZT, string AHH, string CURDOCID, string XZZL, string JCRQ, string KSRQ, string CBSPTBS, string BXZR, string UIXZZL, string XZYY)
    {


        string[] columnNames = new string[] { "FYDM", "AJBS", "AJBH", "XH", "CBTS", "CBR", "AHYEAR", "AHZ", "AHZT", "AHH", "CURDOCID", "XZZL", "JCRQ", "KSRQ", "CBSPTBS", "BXZR", "UIXZZL", "XZYY" };
        string tableName = "B_ZXGZ_XZ";
        try
        {
            DeleteExist(tableName, AJBS, CURDOCID);
            string sqlStr = createInserSqlStr(tableName, columnNames);
            dbService.ExecuteNonQuery(sqlStr, DB2ConnectionString, createHasTable(columnNames, FYDM, AJBS, AJBH, XH, CBTS, CBR, AHYEAR, AHZ, AHZT, AHH, CURDOCID, XZZL, JCRQ, KSRQ, CBSPTBS, BXZR, UIXZZL, XZYY));
        }
        catch (Exception ex)
        {
            return ex.ToString();
        }
        return "success";


    }


    private void DeleteExist(string tableName, string AJBS, string CURDOCID)
    {

        string countsql = string.Format("delete  from {0} where AJBS=@AJBS and CURDOCID=@CURDOCID", tableName);
        dbService.ExecuteNonQuery(countsql, DB2ConnectionString, createHasTable(new string[] { "AJBS", "CURDOCID" }, AJBS, CURDOCID));
    }
    private string createInserSqlStr(string tablename, string[] cols)
    {
        getSometing(cols);
        string sql = "";

        sql = string.Format("insert into {0} ({1}) values ({2})", tablename, ExSystem.ExString.ToString(cols, ","), ExSystem.ExString.ToString(cols, ",", "@", ""));
        return sql;
    }

    private Hashtable createHasTable(string[] cols, params string[] values)
    {
        Hashtable a = new Hashtable();
        int len = cols.Length;
        for (int i = 0; i < len; i++)
        {
            if (string.IsNullOrEmpty(values[i]))
            {
                values[i] = null;
            }
            a.Add(cols[i], values[i]);
        }
        return a;

    }
    private void getSometing(string[] columnNames)
    {
        StringBuilder builder = new StringBuilder();
        string result = "";
        for (int i = 0; i < columnNames.Length; i++)
        {
            builder.Append(string.Format("doc.GetItemValue(\"{0}\")(0)", columnNames[i]));
            builder.Append(",");
        }

        result = ExSystem.ExString.RemoveLastString(builder.ToString(), ",");
        result = result;
    }


}

